home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / intrlib1.zip / MESSAGES.C < prev    next >
C/C++ Source or Header  |  1991-01-19  |  3KB  |  101 lines

  1. /******************************************************************************
  2. * Iteraction library - Messages handler.                      *
  3. *                                          *
  4. *                    Written by Gershon Elber,  Nov. 1990  *
  5. *******************************************************************************
  6. * History:                                      *
  7. *  11 Nov 90 - Version 1.0 by Gershon Elber.                      *
  8. ******************************************************************************/
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdio.h>
  13. #include "intr_loc.h"
  14. #include "intr_gr.h"
  15.  
  16. #define MESSAGE_BORDER_WIDTH 8
  17. #define MESSAGE_BORDER_WIDTH4 (MESSAGE_BORDER_WIDTH / 4)
  18. #define MESSAGE_BORDER_WIDTH2 (MESSAGE_BORDER_WIDTH / 2)
  19.  
  20.  
  21. static IntrBType HasActiveMessage = FALSE;
  22.  
  23. /******************************************************************************
  24. * Routine to put a string message on the top left screen corner.          *
  25. ******************************************************************************/
  26. void IntrDrawMessage(char *Str, IntrColorType ForeColor,
  27.                             IntrColorType BackColor)
  28. {
  29.     int i, Xmax, Ymax, GRLastColor;
  30.  
  31.     if (HasActiveMessage)
  32.     IntrFatalError("Two draw messages with no erase in between.");
  33.  
  34.     /* Save current graphic state. */
  35.     GRPushViewPort();
  36.     _GRSetViewPort(0, 0, GRScreenMaxX, GRScreenMaxY);
  37.  
  38.     GRPushTextSetting();
  39.     GRSetTextJustify(GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP);
  40.     GRSetSTextStyle(GR_FONT_DEFAULT, GR_HORIZ_DIR, GR_TEXT_MAG_1);
  41.  
  42.     GRLastColor = GRGetColor();
  43.  
  44.     Xmax = GRGetTextWidth(Str) + 5;
  45.     Ymax = GRGetTextHeight(Str) + 3;
  46.     if (_IntrSaveBelow)
  47.     _IntrSaveWindow(0, 0,
  48.             Xmax + MESSAGE_BORDER_WIDTH, Ymax + MESSAGE_BORDER_WIDTH);
  49.  
  50.     IntrAllocColor(BackColor, INTR_INTENSITY_HIGH);
  51.     GRSBar(0, 0, Xmax, Ymax);
  52.  
  53.     GRSTextShadow(0, 0, IntrAllocColor(ForeColor, INTR_INTENSITY_VHIGH), Str);
  54.  
  55.     for (i = 0; i < MESSAGE_BORDER_WIDTH4; i++) {
  56.         IntrAllocColor(ForeColor, INTR_INTENSITY_HIGH);
  57.         GRSMoveTo(0, Ymax + i);
  58.         GRSLineTo(Xmax + i, Ymax + i);
  59.         GRSLineTo(Xmax + i, 0);
  60.     }
  61.     IntrAllocColor(ForeColor, INTR_INTENSITY_VHIGH);
  62.     for (; i < MESSAGE_BORDER_WIDTH2 + MESSAGE_BORDER_WIDTH4; i++) {
  63.         GRSMoveTo(0, Ymax + i);
  64.         GRSLineTo(Xmax + i, Ymax + i);
  65.         GRSLineTo(Xmax + i, 0);
  66.     }
  67.     for (; i < MESSAGE_BORDER_WIDTH; i++) {
  68.         IntrAllocColor(ForeColor, INTR_INTENSITY_VLOW);
  69.         GRSMoveTo(0, Ymax + i);
  70.         GRSLineTo(Xmax + i, Ymax + i);
  71.         GRSLineTo(Xmax + i, 0);
  72.     }
  73.  
  74.     /* Restore current graphic state. */
  75.     GRSetColor(GRLastColor);
  76.     GRPopTextSetting();
  77.     GRPopViewPort();
  78.  
  79.     HasActiveMessage = TRUE;
  80. }
  81.  
  82. /******************************************************************************
  83. * Routine to erase the string message from the top left screen corner.          *
  84. ******************************************************************************/
  85. void IntrEraseMessage(void)
  86. {
  87.     if (!HasActiveMessage)
  88.     IntrFatalError("No message to erase.");
  89.  
  90.     /* Save current graphic state. */
  91.     GRPushViewPort();
  92.     _GRSetViewPort(0, 0, GRScreenMaxX, GRScreenMaxY);
  93.  
  94.     if (_IntrSaveBelow) _IntrRestoreWindow();
  95.  
  96.     /* Restore current graphic state. */
  97.     GRPopViewPort();
  98.  
  99.     HasActiveMessage = FALSE;
  100. }
  101.